Skip to content

add pagination#31

Open
peterDijk wants to merge 6 commits intomainfrom
addPagination
Open

add pagination#31
peterDijk wants to merge 6 commits intomainfrom
addPagination

Conversation

@peterDijk
Copy link
Copy Markdown
Owner

@peterDijk peterDijk commented Dec 6, 2024

adding pagination was done in minutes, arriving to tests in current state took some hours of trying and failing.
My issue was with seeding many items, and asserting the order of products.
before i was only testing the list endpoint with 2 manually seeded products.
I started with seeding 100 items, but the order of products (which is ordered by date_added desc) was all over the place.
I did realize quick the seeded products had a date_added that was all similar.

first learning: have Date column including milliseconds.

I still had products that were in added in the exact same millisecond. Tried. a lot of things with adding sleep in the seed method, awaiting the seed etc. Tests were taking a very long time now, did succeed, but not reliable, sometimes still similar date_added.

Stopped with not asserting the items order and just asserting the items returned.

Until driving the car suddenly I realized 'of course i just have to set the date_added myself in the seed, setting a second later for each product. --> quick google I found this in python is done with using timedelta

second learning: in testing, set as many values yourself when you assert the outcome based on those values

def count(self) -> int:
products = self.all()
return len(list(products))
# pylint: disable=not-callable
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why needed here but not at func.sum() ??

@peterDijk peterDijk marked this pull request as ready for review December 8, 2024 08:52
@peterDijk peterDijk changed the title changed datetime to include milliseconds to ensure correct ordering o… add pagination Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant